<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人中心-教练</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>
</head>
<body>
<!-- 顶部开始 -->
<div class="container">
    <div class="logo"><a href="./index.html">健身房管理系统 V1.1</a></div>
    <div class="open-nav"><i class="iconfont">&#xe699;</i></div>
    <ul class="layui-nav right" lay-filter="">
        <li class="layui-nav-item">
            <a href="javascript:;">${logUsername}</a>
            <dl class="layui-nav-child"> <!-- 二级菜单 -->
                <dd><a href="${pageContext.request.contextPath}/coach/toOneselfPage.action">个人中心</a></dd>
                <dd><a href="${pageContext.request.contextPath}/coach/toCoachcourseSchedule.action">课程表</a></dd>
                <dd><a href="${pageContext.request.contextPath}/member/outlogin.action">退出</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item"><a href="/">前台首页</a></li>
    </ul>
</div>
<!-- 顶部结束 -->
<!-- 中部开始 -->
<div class="wrapper">
    <!-- 左侧菜单开始 -->
    <div class="left-nav">
        <div id="side-nav">
            <ul id="nav">
                <li class="list" current>
                    <a href="">
                        <i class="iconfont">&#xe761;</i>
                        欢迎页面
                        <i class="iconfont nav_right">&#xe697;</i>
                    </a>
                </li>
                <%-- 课程表信息模块--%>
                <li class="list">
                    <a href="javascript:;">
                        <i class="iconfont">&#xe70b;</i>
                        课程模块
                        <i class="iconfont nav_right">&#xe697;</i>
                    </a>
                    <ul class="sub-menu">
                        <li>
                            <a href="${pageContext.request.contextPath}/coach/toCoursePage.action">
                                <i class="iconfont">&#xe6a7;</i>
                                课程列表
                            </a>
                        </li>
                        <li>
                            <a href="">
                                <i class="iconfont">&#xe6a7;</i>
                                课程安排
                            </a>
                        </li>
                    </ul>
                </li>
                <%-- 教室信息查看与预定管理--%>
                <li class="list">
                    <a href="javascript:;">
                        <i class="iconfont">&#xe70b;</i>
                        教室模块
                        <i class="iconfont nav_right">&#xe697;</i>
                    </a>
                    <ul class="sub-menu">
                        <li>
                            <a href="${pageContext.request.contextPath}/coach/toClassroomPage.action">
                                <i class="iconfont">&#xe6a7;</i>
                                教室列表
                            </a>
                        </li>
                        <li>
                            <a href="">
                                <i class="iconfont">&#xe6a7;</i>
                                教室安排
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <!-- 左侧菜单结束 -->
    <!-- 右侧主体开始 -->
    <div class="page-content">
        <div class="content">
            <!-- 右侧内容框架，更改从这里开始 -->
            <blockquote class="layui-elem-quote">
                个人中心
            </blockquote>
            <fieldset class="layui-elem-field layui-field-title site-title">
                <legend><a name="default">个人信息</a></legend>
            </fieldset>
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>登录账户</th>
                        <th>登录密码</th>
                        <th>真名</th>
                        <th>性别</th>
                        <th>锻炼方向</th>
                        <th>家庭住址</th>
                        <th>入职日期</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody id="tb1">
                <tr>
                    <td>${logUser.coachLogName}</td>
                    <td>******</td>
                    <td>${logUser.coachrealname}</td>
                    <td>${logUser.coachsex}</td>
                    <td>${logUser.cotype}</td>
                    <td>${logUser.address}</td>
                    <td>
                        <fmt:formatDate value="${logUser.hiredate}" pattern="yyyy-MM-dd"/>
                    </td>
                    <td class="td-status">
                        <span class="layui-btn layui-btn-normal layui-btn-mini" onclick="member_edit('编辑','${pageContext.request.contextPath}/coachOneself-edit.jsp','4','','550')">编辑</span>
                    </td>
                </tr>
                </tbody>
            </table>

            <fieldset class="layui-elem-field layui-field-title site-title">
                <legend><a name="default">学员预约情况</a></legend>
            </fieldset>
            <table class="layui-table" id="tb2">
                <thead>
                <tr>
                    <td hidden>预约表的id</td>
                    <th>学员</th>
                    <th>商定日期</th>
                    <th>时长</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="tb44">
                    <c:forEach items="${resMem}" var="reserve">
                        <tr>
                            <td hidden>${reserve.reserveid}</td>
                            <td>${reserve.member.memrealname}</td>
                            <td><c:if test="${reserve.reservedate==null}">未商定</c:if>
                                <fmt:formatDate value="${reserve.reservedate}" pattern="yyyy-MM-dd"/>
                            </td>
                            <td>一个月</td>
                            <td> <span class="layui-btn layui-btn-normal layui-btn-mini" onclick="delMem(${reserve.reserveid})">到期删除</span></td>
                        </tr>
                    </c:forEach>
                </tbody>
            </table>
                <span id="span_4"></span>
            <!-- 右侧内容框架，更改从这里结束 -->
        </div>
    </div>
    <!-- 右侧主体结束 -->
</div>
<!-- 中部结束 -->

<!-- 背景切换开始 -->
<!-- 背景切换结束 -->
<script>
    // 用户-编辑
    function member_edit (title,url,id,w,h) {
        x_admin_show(title,url,w,h);
    }

    //获取用户教练预约情况,弃用
    function infor2() {
        $.ajax({
            url:"${pageContext.request.contextPath}/coach/getAllMem.action",
            type:"post",
            data:{coachid:"${logUser.coachid}"},
            dataType:"json",
            success:function (result) {
                if (result!=null){
                    //先删除原来的
                    $("#tb44").children().remove();
                    $(result).each(function (index,item){
                        var states;
                        //判断课程状态
                        if (item.reservestates=="0"){
                            states="到期";
                        }else if (item.reservestates=="1"){
                            states="未到期";
                        }
                        $("#tb44").append("<tr><td hidden>"+item.reserveid+"</td><td>"+item.member.memrealname+"</td><td>"+item.reservedate+
                            "</td><td>"+"一个月"+"</td><td>"+states+"</td><td>"+"操作"+"</td></tr>");
                    });
                }else {
                    $("#span_4").html("您没有学员");
                }
            },
            error:function (){

            }
        });
    }

    // infor2();
    //删除到期会员
    function delMem(id) {
        layer.confirm("确定删除吗",function (){
            $.ajax({
                url:"${pageContext.request.contextPath}/coach/delMem.action",
                type:"post",
                data:{reserveid:id},
                dataType:"text",
                success:function (result) {
                    if (result=="ok"){
                        layer.msg('删除成功', {icon: 1});
                        // window.load("http://localhost:8080/GamnasiumSystem/coach/toOneselfPage.action");
                    }else {
                        layer.msg('已删除，请刷新！', {icon: 1});
                    }
                },
                error:function (){
                    console.log("error");
                }
            });
        });
        <%--location.href="${pageContext.request.contextPath}/coach/toOneselfPage.action";--%>
    }
    //商定价格之后，自己修改。未决定
    function changeDate(index) {
        console.log(index.innerText);
        $.ajax({
            url:"${pageContext.request.contextPath}/member/changeDate.action",
            type:"post",
            data:{reserveid:index.innerText},
            dataType:"text",
            success:function (result) {
                if (result=="ok"){
                    x_admin_show('日期修改','${pageContext.request.contextPath}/memdate-edit.jsp','','200');
                }else {
                    alert("无法修改");
                }
            },
            error:function (){
                alert("error");
            }
        });
    }
</script>
</body>
</html>
